<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css"></style>
</head>
<body>
    <h1>location</h1>
    <hr>

    <button onclick="location.reload()">刷新</button>
    
    <!-- 跳转加载指定页面 -->
    <button onclick="location.assign('http://www.jd.com')">assign</button>
    <button onclick="location.replace('http://www.taobao.com')">replace</button>
    <button onclick="location.href = 'http://www.vip.com'">href</button>


    <script>
        // console.dir(window.location);
        
        console.log('URL: ' + location.href);
        // http://127.0.0.1/s94/JavaScript/BOM/index.html?name=%E8%80%81%E7%8E%8B&age=18#p11
        // %E8%80%81%E7%8E%8B   => 老王    URL转码
        
        console.log('协议: ' + location.protocol);
        console.log('域名/主机名: ' + location.hostname);
        console.log('域名/主机名 + 端口号: ' + location.host);
        console.log('路径+文件名 (path): ' + location.pathname); // 路径/路由
        console.log('参数: ' + location.search);
        console.log('锚点: ' + location.hash);

        // location.href = 'www.huaban.com'; // NO
        // location.href = 'http://www.huaban.com';

        // location.search = '?sex=0';
        // location.hash = '#p99';
    

    </script>



</body>
</html>


